package com.cctc.mychat.common.protocol.codec;

import com.cctc.mychat.common.protocol.message.Message;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

public class MessageDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf byteBuf, List<Object> list) throws Exception {
        Message message = MessageCodecManager.decode(byteBuf);
        if (message != null) list.add(message);
    }
}
